<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8"/>
    <title>文档全文检索</title>
</head>

<body class="pg">
<div class="page" id="app">
    <input type="text" name="search" v-on:keyup.enter="searchPage" v-model="keyword">
    <button @click.prevent="searchPage"  type="submit" id="searchbtn">搜索</button>
    <div class="product" v-for="item in results">
        <div>
            <span style="color: #3388bb">序号：</span>{{item.index}}
        </div>
        <div>
            <span style="color: #3388bb">文件名称：</span>{{item.fileName}}
        </div>
            <span style="color: #3388bb">搜到的内容↘ </span><p v-html = "item.fileContent_fragments"/>
        <hr>
    </div>
</div>
<script th:src="@{/js/vue.min.js}"></script>
<script th:src="@{/js/axios.min.js}"></script>
<script>
    new Vue({
        el:'#app',
        data:{
            keyword:'',  //搜索关键字
            results:[],  //搜索结果
        },
        methods:{
            searchPage(){
                var keyword = this.keyword;
                console.log(keyword)
                axios.get("/searchDocument/"+keyword).then(res=>{
                    console.log(res.data)
                    this.results = res.data;
                })
            }
        }
    })
</script>

</body>
</html>